<!-- 我的绩效-绩效评价任务-绩效考核 -->
<template>
  <div class="base-setting">
    <div class="wrap">
      <ConditionBox :margin-bottom="20">
        <template #left>
          <a-space>
            <a-select :style="{ width: '120px' }" placeholder="请选择">
              <a-option :valule="1">名称</a-option>
              <a-option :valule="1">岗位</a-option>
              <a-option :valule="1">部门</a-option>
            </a-select>
            <a-select :style="{ width: '120px' }" placeholder="考核类型">
              <a-option :valule="1">试用期考核</a-option>
              <a-option :valule="1">绩效考核</a-option>
              <a-option :valule="1">晋升考核</a-option>
              <a-option :valule="1">任期考核</a-option>
            </a-select>
            <a-input-search
              :style="{ width: '220px' }"
              placeholder="姓名/工号"
              search-button
              @search="onSearch"
              @press-enter="onSearch"
              v-model="nameSearch"
            />
          </a-space>
        </template>
        <template #right>
          <a-space>
            <a-select :style="{ width: '120px' }" placeholder="考核工具">
              <a-option :valule="1">BPI</a-option>
              <a-option :valule="1">BPP</a-option>
              <a-option :valule="1">OPI</a-option>
            </a-select>
            <a-button :type="'primary'">批量评分</a-button>
          </a-space>
        </template>
      </ConditionBox>
      <table-turn :table-data="getTableData" ref="tableRef" :args="args">
        <a-table-column :width="80">
          <template #title> 序号 </template>
          <template #cell="{ rowIndex }">
            {{ rowIndex + 1 }}
          </template>
        </a-table-column>
        <a-table-column
          :width="200"
          align="center"
          data-index="name"
          title="绩效考核名称"
        >
        </a-table-column>
        <a-table-column
          :width="200"
          align="center"
          data-index="definition"
          title="考核对象"
        >
        </a-table-column>
        <a-table-column
          :width="200"
          align="center"
          data-index="definition"
          title="工号"
        >
        </a-table-column>
        <a-table-column
          :width="200"
          align="center"
          data-index="definition"
          title="部门"
        >
        </a-table-column>
        <a-table-column
          :width="200"
          align="center"
          data-index="definition"
          title="职位"
        >
        </a-table-column>
        <a-table-column
          :width="200"
          align="center"
          data-index="definition"
          title="考核类别"
        >
        </a-table-column>
        <a-table-column
          :width="200"
          align="center"
          data-index="definition"
          title="考核周期"
        >
        </a-table-column>
        <a-table-column
          :width="200"
          data-index="definition"
          title="考核到期天数"
        >
        </a-table-column>
        <a-table-column
          :width="120"
          align="center"
          data-index=""
          title="操作"
          fixed="right"
        >
          <template #cell="{ record }">
            <a-tooltip content="评分">
              <IconFont
                type="icon-edit"
                :size="26"
                :style="{
                  cursor: 'pointer'
                }"
                @click="goEdit(record)"
              />
            </a-tooltip>
          </template>
        </a-table-column>
      </table-turn>
    </div>
  </div>
</template>

<script lang="ts" setup>
import { getProbationEvaluateList } from '@/apis/human/base/variationManager/probation';
import TableTurn, { paramsType } from '@/components/TableTurn/index.vue';
const router = useRouter();

const props = withDefaults(
  defineProps<{
    state: number; // 状态 1待评价 2已评价 3抄送我的
  }>(),
  {}
);

let modalVisible = ref(false); // 判断新增弹出框是否打开
let currData = ref(); // 储存当前选中数据
let tableRef = ref();
let nameSearch = ref(''); // 搜索框的值

// 表格配置
const args = reactive({
  rowSelection: {
    type: 'checkbox',
    showCheckedAll: true,
    onlyCurrent: false
  }
});

// 获取表格数据
const getTableData = async (params: paramsType) => {
  try {
    const res = await getProbationEvaluateList({
      ...params,
      listType: props.state
    });
    // const res: any = originData.value.find(
    //   (item: any) => item.id === currId.value
    // );
    // res.content = res.personnelChange;
    return Promise.resolve(res);
  } catch (error: unknown) {
    console.log(error);
  }
};

// 点击搜索框
const onSearch = () => {
  refresh();
};

// 编辑
const goEdit = (record: any) => {
  // console.log(record);
  router.push({
    name: 'MyProbationAssessmentDetail',
    query: { id: record.id }
  });
};

// 删除某一行
const del = async (id: number) => {
  try {
    // await DelHumanChangeSetting({ id });
    refresh();
  } catch (error: unknown) {
    console.log(error);
  }
};

// 弹窗自定义事件
const indexEmit = async (record: any) => {
  //
};

// 刷新表格数据
const refresh = () => {
  tableRef.value.loadData();
};
</script>

<style scoped lang="less">
.wrap {
  // padding: 20px;

  .header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
  }
}
</style>
